#
#    Copyright 2007 Andrew Wilkinson <andrew@indiegigs.co.uk>.
#
#    This file is part of Transport Manager (http://code.google.com/p/transportmanager/)
#
#    Transport Manager is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2.0 of the License, or
#    (at your option) any later version.
#
#    Transport Manager is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Lesser General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Transport Manager; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

from PyQt4 import QtCore, QtGui, QtOpenGL

class Screen(QtGui.QWidget):
    def __init__(self):
        QtGui.QWidget.__init__(self)

        self.scene = QtGui.QGraphicsScene()
        self.view = QtGui.QGraphicsView(self.scene)

        fmt = QtOpenGL.QGLFormat()
        fmt.setSampleBuffers(True)
        self.view.setViewport(QtOpenGL.QGLWidget(fmt))
        self.view.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.view.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)

        self.width, self.height = 800, 600
        self.view.resize(self.width, self.height)
        self.view.centerOn(self.width/2, self.height/2)

        self.timer = QtCore.QBasicTimer()
        self.timer.start(1000.0/24, self)

    def run(self):
        self.view.show()

        app.exec_()

    def timerEvent(self, _):
        world.update(1.0/24)
